#ifndef PRCONFIG_H
#define PRCONFIG_H

#include <QObject>
#include "configarray.h"
#include "configfile.h"
#include "configobject.h"
#include "configobjectarray.h"

static QVariantList cameraList;

class PRConfigParameter : public ConfigObject
{
public:
    const QString PR_NCC_OBJECT_TEMPLATE = "NCC OBJECT";
    const QString PR_EDGE_MODEL_TEMPLATE = "EDGE";

    Q_OBJECT
    Q_PROPERTY(QString prName READ prName WRITE setPRName NOTIFY prNameChanged)
    Q_PROPERTY(QString cameraName READ cameraName WRITE setCameraName NOTIFY cameraNameChanged)
    Q_PROPERTY(QString prType READ prType WRITE setPRType NOTIFY prTypeChanged)
    Q_PROPERTY(double xResolution READ xResolution WRITE setXResolution NOTIFY xResolutionChanged)
    Q_PROPERTY(double yResolution READ yResolution WRITE setYResolution NOTIFY yResolutionChanged)

public:
    PRConfigParameter(QObject *parent = nullptr) : ConfigObject(parent)
    {
        {
            QVariantList stringOptions;
            stringOptions.append(PR_NCC_OBJECT_TEMPLATE);
            stringOptions.append(PR_EDGE_MODEL_TEMPLATE);
            setOptionalProperty("prType", stringOptions);
        }
        {
            setOptionalProperty("cameraName", cameraList);
        }
        init();
    }

    QString m_prName = "dummy";
    QString m_cameraName = "cameraName";
    QString m_prType = PR_NCC_OBJECT_TEMPLATE;
    double m_xResolution = 0;
    double m_yResolution = 0;

    QString prName() const
    {
        return m_prName;
    }

    QString cameraName() const
    {
        return m_cameraName;
    }

    QString prType() const
    {
        return m_prType;
    }

    double xResolution() const
    {
        return m_xResolution;
    }

    double yResolution() const
    {
        return m_yResolution;
    }

public slots:
    void setPRName(QString prName)
    {
        if (m_prName == prName)
            return;

        m_prName = prName;
        emit prNameChanged(m_prName);
    }
    void setCameraName(QString cameraName)
    {
        if (m_cameraName == cameraName)
            return;

        m_cameraName = cameraName;
        emit prNameChanged(m_prName);
    }
    void setPRType(QString prType)
    {
        if (m_prName == prType)
            return;
        m_prType = prType;
        emit prTypeChanged(m_prType);
    }
    void setXResolution(double xResolution)
    {
        m_xResolution = xResolution;
        emit xResolutionChanged(xResolution);
    }
    void setYResolution(double yResolution)
    {
        m_yResolution = yResolution;
        emit yResolutionChanged(yResolution);
    }
signals:
    void prNameChanged(QString prName);
    void cameraNameChanged(QString cameraName);
    void prTypeChanged(QString prType);
    void xResolutionChanged(double xResolution);
    void yResolutionChanged(double yResolution);
};

class PRConfig : public ConfigObject
{
    Q_OBJECT
    Q_PROPERTY(ConfigObjectArray *prConfigParameterArray READ prConfigParameterArray)

    ConfigObjectArray * m_prConfigParameterArray;

public:
    PRConfig(QObject *parent = nullptr) : ConfigObject(parent)
    {
        m_prConfigParameterArray = new ConfigObjectArray("PRConfigParameter");
        m_prConfigParameterArray->setObjectName("m_cameraParameterArray");
        init();
    }

    ConfigObjectArray * prConfigParameterArray() const
    {
        return m_prConfigParameterArray;
    }
};

#endif // PRCONFIG_H
